import numpy as np
from python_ai.common.xcommon import *
import matplotlib.pyplot as plt

path = r'../../../../large_data/DL1/image_numpy/'
data = np.loadtxt(path + 'img_16_10k.txt', delimiter=',')
check_shape(data, 'data')

# data, labels = np.split(data, [-1], axis=1)
data, labels = np.hsplit(data, [-1])
check_shape(data, 'data')
check_shape(labels, 'labels')

data = data.reshape([-1, 16, 16])

spr = 4
spc = 6
spn = 0
plt.figure(figsize=[12, 8])

for i in range(spr * spc):
    img = data[i]
    spn += 1
    plt.subplot(spr, spc, spn)
    plt.axis('off')
    plt.imshow(img)
    plt.title(str(int(labels[i])))

plt.show()
